package com.ews.onlineexchange.model.approved;

import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import com.ews.onlineexchange.model.DataEntity;

@Entity
public class ApprovedClass extends DataEntity {
	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	private String				name;
	private ApprovedType		approvedType;				
	private BigDecimal			sumScore;

	@NotNull
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Enumerated(EnumType.STRING)
	@NotNull
	public ApprovedType getApprovedType() {
		return approvedType;
	}

	public void setApprovedType(ApprovedType approvedType) {
		this.approvedType = approvedType;
	}

	@NotNull
	@Min(1L)
	public BigDecimal getSumScore() {
		return sumScore;
	}

	public void setSumScore(BigDecimal sumScore) {
		this.sumScore = sumScore;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((sumScore == null) ? 0 : sumScore.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		ApprovedClass other = (ApprovedClass) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (sumScore == null) {
			if (other.sumScore != null)
				return false;
		} else if (!sumScore.equals(other.sumScore))
			return false;
		return true;
	}

}
